package org.cloud.controller;

import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.cloud.model.dto.PayDto;
import org.cloud.response.ResultData;
import org.cloud.service.IAliPayService;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * ClassName: PayController
 * Package: org.cloud.controller
 * Description:
 *
 * @Author: @weixueshi
 * @Create: 2024/4/10 - 21:30
 * @Version: v1.0
 */
@RestController
@RequestMapping("/pay")
@RequiredArgsConstructor
public class AliPayController {

    public final IAliPayService payService;

    /**
     * 支付新增接口
     * @param payDto
     * @return
     */
    @PostMapping("/add")
    @Operation(summary = "新增",description = "支付接口")
    public ResultData addPayment(@RequestBody PayDto payDto){
        payService.addPayment(payDto);
        return ResultData.success();
    }

    /**
     * 查询支付接口
     * @param orderNo
     * @return
     */
    @GetMapping("/query/{orderNo}")
    @Operation(summary = "查询",description = "查询支付接口")
    public ResultData queryOrder(@PathVariable("orderNo") String orderNo){
        List<PayDto> payDto = payService.queryOrder(orderNo);
        return ResultData.success(payDto);
    }
}
